import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Home.vue'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Layout,
    redirect: '/home',
    children: [
      { path: 'home', component: () => import('../views/WorkBench.vue') },
      // { path: 'dtld-material-truck', component: () => import('../views/MaterialTruck.vue') },
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: Login,
  },
]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
